

xml = Builder::XmlMarkup.new
xml.chart(:showMean=>1, :caption=> caption) do
	# Run a loop to create the <category> tags within <categories>
  xml.categories do
		for item in arr_data
			xml.category(:name=>item[0])
		end
	end
	# Run a loop to create the <set> tags within dataset for series 'R-factor'
  xml.dataset(:seriesName=>'r_factor') do
		for item in arr_data
      url = url_for(:action=>"detail", :id=>item[0].gsub(".","_"), :date=>params[:date].gsub("\/","_"))  
			xml.set(:value=>item[1..item.size].join(','), :link=>"#{url}")
		end

	end
	
end